package com.chenyongjing.design.pattern.state.general.apply;

/**
 * @Author chen
 * @Date 2022/11/20 19:16
 */
public class Context {
    private static final State STATE_A =new ConcreteStateA();
    private static final State STATE_B =new ConcreteStateB();

    private State currentState = STATE_A;

    {
        STATE_A.setContext(this);
        STATE_B.setContext(this);
    }

    void setState(State state){
        this.currentState=state;
        this.currentState.setContext(this);
    }
    void handle(){
        this.currentState.handle();
    }

}
